#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QColor>
#include <QColorDialog>
#include <QMessageBox>
#include <QFontDialog>
#include <QFileDialog>
#include <QDebug>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_pushButton_clicked()
{
    QColor co = QColorDialog::getColor(Qt::red, this, "我的颜色选择框");
    if(co.isValid())
    {
        QString qss = QString("color: rgb(%1, %2, %3);").arg(co.red()).arg(co.green()).arg(co.blue());
        ui->pushButton->setStyleSheet(qss);
    }
    else
    {
        QMessageBox::information(this, "提示","您取消了颜色选择");
    }
}


void MainWindow::on_pushButton_font_clicked()
{
    bool ok;
    QFontDialog::getFont(&ok, this);
}


void MainWindow::on_pushButton_file_clicked()
{
    QString url = QFileDialog::getOpenFileName(this, "文件选择对话框", "/", "*");
    qDebug() << url.isEmpty();
    qDebug() << url;

}

